<template>
    <el-date-picker
        :disabled="baseInfo.disabled"
        v-model="value"
        :type="baseInfo.type||'date'"
        :style="baseInfo.domCss"
        :value-format="baseInfo.format||'yyyy-MM-dd'"
        :format="baseInfo.format||'yyyy-MM-dd'"
        @change="Change('change')"
        :placeholder="baseInfo.placeholder"
    ></el-date-picker>
</template>

<script>
export default {
    props: {
        baseInfo: {
            type: Object,
            default: () => {
                return {
                    disabled: false,
                    domCss: "",
                    key: "",
                    placeholder: "请选择开始时间",
                    defaultValue: "",
                    type: "date",
                    format: "yyyy-MM-dd"
                };
            }
        }
    },
    data() {
        return {
            value: ""
        };
    },
    created() {
        this.value = this.baseInfo.defaultValue;
    },
    watch: {
        baseInfo: {
            immediate: true,
            deep: true,
            handler: function(v) {
                this.value = this.baseInfo.defaultValue;
            }
        }
    },
    methods: {
        Change(type) {
            this.$emit("EventHandler", type, this.baseInfo.key, this.value);
        }
    }
};
</script>

<style></style>
